<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom Graphs - Apache JMeter Dashboard</title>
    <link rel="icon" type="image/x-icon" href="content/favicon.ico">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f8f9fa;
            color: #333;
        }
        .sidebar {
            position: fixed;
            left: 0;
            top: 0;
            width: 230px;
            height: 100vh;
            background: #f8f9fa;
            border-right: 1px solid #dee2e6;
            overflow-y: auto;
        }
        .main-content {
            margin-left: 230px;
            padding: 20px;
        }
        .header {
            background: #fff;
            padding: 15px 20px;
            border-bottom: 1px solid #dee2e6;
            margin-bottom: 20px;
        }
        .header h1 {
            margin: 0;
            font-size: 24px;
            color: #495057;
            font-weight: normal;
        }
        .nav-menu {
            padding: 20px 0;
        }
        .nav-item {
            display: block;
            padding: 10px 20px;
            color: #495057;
            text-decoration: none;
            border-left: 3px solid transparent;
            transition: all 0.2s;
        }
        .nav-item:hover {
            background: #e9ecef;
            text-decoration: none;
            color: #495057;
        }
        .nav-item.active {
            background: #e3f2fd;
            color: #1976d2;
            border-left-color: #1976d2;
        }
        .nav-item i {
            margin-right: 8px;
            width: 16px;
        }
        .chart-container {
            margin: 20px 0;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 8px;
        }
        .chart-title {
            font-size: 1.2em;
            font-weight: bold;
            margin-bottom: 15px;
            color: #495057;
        }
        .footer {
            background: #f8f9fa;
            padding: 20px;
            text-align: center;
            color: #6c757d;
            border-top: 1px solid #dee2e6;
        }
    </style>
</head>
<body>
    <div class="sidebar">
        <div class="nav-menu">
            <a href="../index.html" class="nav-item">
                <i>📊</i> Dashboard
            </a>
            <a href="charts.html" class="nav-item">
                <i>📈</i> Charts
            </a>
            <a href="custom-graphs.html" class="nav-item active">
                <i>📋</i> Custom Graphs
            </a>
        </div>
    </div>

    <div class="main-content">
        <div class="header">
            <h1>Custom Graphs - Apache JMeter Dashboard</h1>
            <div class="test-info">
                <span>Test Date: 2024-01-15 14:30:00</span>
                <span>Duration: 2.5 hours</span>
                <span>Data Scale: 100 million cold records</span>
            </div>
        </div>

        <div class="chart-container">
            <div class="chart-title">Response Time Percentiles Over Time (successful responses)</div>
            <div style="background: #fff; padding: 15px; border: 1px solid #dee2e6; margin: 10px 0;">
                <canvas id="percentilesChart" width="800" height="300" style="max-width: 100%; height: 300px; background: linear-gradient(to right, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%);"></canvas>
                <div style="margin-top: 10px; font-size: 12px; color: #6c757d; text-align: center;">
                    <span style="color: #28a745;">■</span> 90th Percentile: 145ms | 
                    <span style="color: #ffc107;">■</span> 95th Percentile: 168ms | 
                    <span style="color: #dc3545;">■</span> 99th Percentile: 285ms
                </div>
                <script>
                    // Simulated percentiles chart
                    const percentilesCanvas = document.getElementById('percentilesChart');
                    const percentilesCtx = percentilesCanvas.getContext('2d');
                    
                    // 90th percentile line
                    percentilesCtx.strokeStyle = '#28a745';
                    percentilesCtx.lineWidth = 2;
                    percentilesCtx.beginPath();
                    for(let i = 0; i < 800; i += 10) {
                        const y = 180 + Math.sin(i/50) * 20 + Math.random() * 10;
                        if(i === 0) percentilesCtx.moveTo(i, y); else percentilesCtx.lineTo(i, y);
                    }
                    percentilesCtx.stroke();
                    
                    // 95th percentile line
                    percentilesCtx.strokeStyle = '#ffc107';
                    percentilesCtx.beginPath();
                    for(let i = 0; i < 800; i += 10) {
                        const y = 150 + Math.sin(i/60) * 25 + Math.random() * 12;
                        if(i === 0) percentilesCtx.moveTo(i, y); else percentilesCtx.lineTo(i, y);
                    }
                    percentilesCtx.stroke();
                    
                    // 99th percentile line
                    percentilesCtx.strokeStyle = '#dc3545';
                    percentilesCtx.beginPath();
                    for(let i = 0; i < 800; i += 10) {
                        const y = 100 + Math.sin(i/40) * 35 + Math.random() * 15;
                        if(i === 0) percentilesCtx.moveTo(i, y); else percentilesCtx.lineTo(i, y);
                    }
                    percentilesCtx.stroke();
                </script>
            </div>
        </div>
        
        <div class="chart-container">
            <div class="chart-title">Active Threads Over Time</div>
            <div style="background: #fff; padding: 15px; border: 1px solid #dee2e6; margin: 10px 0;">
                <canvas id="threadsChart" width="800" height="300" style="max-width: 100%; height: 300px; background: linear-gradient(to right, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%);"></canvas>
                <div style="margin-top: 10px; font-size: 12px; color: #6c757d; text-align: center;">
                    <span style="color: #007bff;">■</span> Peak Threads: 50 | 
                    <span style="color: #6610f2;">■</span> Average Threads: 42 | 
                    <span style="color: #20c997;">■</span> Min Threads: 10
                </div>
                <script>
                    // Simulated active threads chart
                    const threadsCanvas = document.getElementById('threadsChart');
                    const threadsCtx = threadsCanvas.getContext('2d');
                    
                    // Fill area under curve
                    threadsCtx.fillStyle = 'rgba(0, 123, 255, 0.1)';
                    threadsCtx.beginPath();
                    threadsCtx.moveTo(0, 300);
                    for(let i = 0; i < 800; i += 10) {
                        let threads;
                        if(i < 100) threads = 250 - (i * 1.5); // Ramp up
                        else if(i < 600) threads = 100 + Math.sin(i/30) * 20; // Steady state
                        else threads = 100 + ((i-600) * 0.8); // Ramp down
                        threadsCtx.lineTo(i, threads);
                    }
                    threadsCtx.lineTo(800, 300);
                    threadsCtx.fill();
                    
                    // Draw line
                    threadsCtx.strokeStyle = '#007bff';
                    threadsCtx.lineWidth = 3;
                    threadsCtx.beginPath();
                    for(let i = 0; i < 800; i += 10) {
                        let threads;
                        if(i < 100) threads = 250 - (i * 1.5);
                        else if(i < 600) threads = 100 + Math.sin(i/30) * 20;
                        else threads = 100 + ((i-600) * 0.8);
                        if(i === 0) threadsCtx.moveTo(i, threads); else threadsCtx.lineTo(i, threads);
                    }
                    threadsCtx.stroke();
                </script>
            </div>
        </div>

        <div class="chart-container">
            <div class="chart-title">Transactions Per Second</div>
            <div style="background: #fff; padding: 15px; border: 1px solid #dee2e6; margin: 10px 0;">
                <canvas id="tpsChart" width="800" height="300" style="max-width: 100%; height: 300px; background: linear-gradient(to right, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%);"></canvas>
                <div style="margin-top: 10px; font-size: 12px; color: #6c757d; text-align: center;">
                    <span style="color: #28a745;">■</span> Peak TPS: 36.7/sec | 
                    <span style="color: #17a2b8;">■</span> Average TPS: 29.3/sec | 
                    <span style="color: #fd7e14;">■</span> Min TPS: 8.2/sec
                </div>
                <script>
                    // Simulated TPS chart with bar representation
                    const tpsCanvas = document.getElementById('tpsChart');
                    const tpsCtx = tpsCanvas.getContext('2d');
                    
                    // Draw bars for TPS
                    tpsCtx.fillStyle = '#28a745';
                    for(let i = 0; i < 800; i += 20) {
                        const tps = 150 + Math.sin(i/40) * 40 + Math.random() * 30;
                        const barHeight = 300 - tps;
                        tpsCtx.fillRect(i, tps, 15, barHeight);
                    }
                    
                    // Add trend line
                    tpsCtx.strokeStyle = '#17a2b8';
                    tpsCtx.lineWidth = 3;
                    tpsCtx.beginPath();
                    for(let i = 0; i < 800; i += 10) {
                        const tps = 150 + Math.sin(i/50) * 35 + Math.random() * 20;
                        if(i === 0) tpsCtx.moveTo(i, tps); else tpsCtx.lineTo(i, tps);
                    }
                    tpsCtx.stroke();
                    
                    // Add grid lines
                    tpsCtx.strokeStyle = '#e9ecef';
                    tpsCtx.lineWidth = 1;
                    for(let i = 50; i < 300; i += 50) {
                        tpsCtx.beginPath();
                        tpsCtx.moveTo(0, i);
                        tpsCtx.lineTo(800, i);
                        tpsCtx.stroke();
                    }
                </script>
            </div>
        </div>

        <div class="chart-container">
            <div class="chart-title">Response Time Distribution</div>
            <div style="background: #fff; padding: 15px; border: 1px solid #dee2e6; margin: 10px 0;">
                <canvas id="distributionChart" width="800" height="300" style="max-width: 100%; height: 300px; background: linear-gradient(to right, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%);"></canvas>
                <div style="margin-top: 10px; font-size: 12px; color: #6c757d; text-align: center;">
                    <span style="color: #6f42c1;">■</span> 0-50ms: 18,245 requests | 
                    <span style="color: #007bff;">■</span> 50-100ms: 15,832 requests | 
                    <span style="color: #28a745;">■</span> 100-200ms: 8,456 requests | 
                    <span style="color: #ffc107;">■</span> 200ms+: 1,467 requests
                </div>
                <script>
                    // Simulated response time distribution histogram
                    const distributionCanvas = document.getElementById('distributionChart');
                    const distributionCtx = distributionCanvas.getContext('2d');
                    
                    // Define histogram data (response time ranges and counts)
                    const histogramData = [
                        {range: '0-25ms', count: 180, color: '#6f42c1'},
                        {range: '25-50ms', count: 220, color: '#007bff'},
                        {range: '50-75ms', count: 190, color: '#17a2b8'},
                        {range: '75-100ms', count: 160, color: '#28a745'},
                        {range: '100-150ms', count: 120, color: '#20c997'},
                        {range: '150-200ms', count: 80, color: '#ffc107'},
                        {range: '200-300ms', count: 40, color: '#fd7e14'},
                        {range: '300ms+', count: 20, color: '#dc3545'}
                    ];
                    
                    // Draw histogram bars
                    const barWidth = 90;
                    histogramData.forEach((data, index) => {
                        const x = index * 100 + 20;
                        const barHeight = data.count;
                        const y = 280 - barHeight;
                        
                        distributionCtx.fillStyle = data.color;
                        distributionCtx.fillRect(x, y, barWidth, barHeight);
                        
                        // Add labels
                        distributionCtx.fillStyle = '#6c757d';
                        distributionCtx.font = '10px Arial';
                        distributionCtx.fillText(data.range, x + 5, 295);
                        distributionCtx.fillText(data.count, x + 25, y - 5);
                    });
                </script>
            </div>
        </div>

        <div class="footer">
            <p>Report Generated: 2024-01-15 16:45:00 | JMeter Version: 5.5 | Test Executor: Performance Test Team</p>
            <p>© 2024 Distributed KV Service Performance Test Report - Generated with Apache JMeter</p>
        </div>
    </div>
</body>
</html>